
#!/bin/bash

# 拉取测试机的数据库备份

mysqlBakIp='124.202.152.242'
#filenam='minisdk.2015021018.sql.tar.gz'
yesDay=`date +%Y%m%d -d "1 days ago"`
fileName='minisdk'.$yesDay.'tar.gz'
dirName='/home/sdkmysqlbak'/`date '+%Y%m'`
sqlFileName='minisdk'.$yesDay.'sql'
if [ ! -x "$dirName" ]; then
  mkdir "$dirName"
fi


scp root@$mysqlBakIp:/root/sdkmysqlbak/$fileName $dirName

cd $dirName

tar -zxvf $dirName

mysql -uroot -p123456 minisdk_sec < $sqlFileName

rm -rf $sqlFileName